package dataPersistence;

import hitExceptions.InvalidOperationException;
import coreModel.HIT;
import coreModel.SerializableImplementer;
import dataPersistence.dao.IItemDAO;
import dataPersistence.dao.IProductDAO;
import dataPersistence.dao.IProductGroupDAO;
import dataPersistence.dao.IStorageUnitDAO;
import dataPersistence.dao.Item_DB_DAO;
import dataPersistence.dao.Item_Serial_DAO;
import dataPersistence.dao.ProductGroup_Serial_DAO;
import dataPersistence.dao.Product_Serialized_DAO;
import dataPersistence.dao.StorageUnit_Serial_DAO;

public class Serial_DAOFactory extends SerializableImplementer implements DataPersistenceFactory
{

	@Override
	public IItemDAO getItemDAO()
	{
		return new Item_Serial_DAO();
	}

	@Override
	public IProductDAO getProductDAO()
	{
		return new Product_Serialized_DAO();
	}

	@Override
	public IProductGroupDAO getProductGroupDAO()
	{
		return new ProductGroup_Serial_DAO();
	}

	@Override
	public IStorageUnitDAO getStorageUnitDAO()
	{
		return new StorageUnit_Serial_DAO();
	}

	@Override
	public void load()throws InvalidOperationException
	{
		HIT.getInstance().getSerializer().loadObjects();
	}

	@Override
	public void save()throws InvalidOperationException
	{
		HIT.getInstance().getSerializer().saveObjects(HIT.getInstance());
	}

	@Override
	public void load(String file) throws InvalidOperationException
	{
		HIT.getInstance().getSerializer().loadObjects(file);
		
	}

	@Override
	public void save(String file) throws InvalidOperationException
	{
		HIT.getInstance().getSerializer().saveObjects(HIT.getInstance(), file);
		
	}

}
